import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;
import java.util.Map;

public class Homework_UdpDictServer extends Homework_UdpEchoServer{
    //使用哈希表创建词典
    private Map<String, String> dict = new HashMap<>();
    public Homework_UdpDictServer(int port) throws SocketException {
        super(port);
        dict.put("cat", "小猫");
        dict.put("dog", "小狗");
        dict.put("pig", "小猪");
        dict.put("chick", "小鸡");
    }
    @Override
    public String process(String request) {
        return dict.getOrDefault(request, "未找到该词汇");
    }

    public static void main(String[] args) throws IOException {
        Homework_UdpDictServer server = new Homework_UdpDictServer(9999);
        server.start();
    }
}
